package com.tom.architect02.structure.tree1;

import android.content.Intent;

import androidx.appcompat.app.AppCompatActivity;

import com.example.lib_personal.LoginActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Added by Tom on 2024/02/20.
 */
public class BaseActivity extends AppCompatActivity {
    // 需要登录的ActivityClassNames
    private static List<String> mNeedLoginClassNames;
    static {
        mNeedLoginClassNames = new ArrayList<>();
//        mNeedLoginClassNames.add(LiveActivity.class.getName());
    }

    // startActivity，最终会调用startActivityForResult
    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        String className = intent.getComponent().getClassName();
        if (mNeedLoginClassNames.contains(className)) {
            // 判断有没有登录成功， 进行拦截
            Intent loginIntent = new Intent(this, LoginActivity.class);
            loginIntent.putExtra("target", intent);
            super.startActivity(loginIntent);
            return;
        }
        super.startActivityForResult(intent, requestCode);
    }

/*    @Override
    public void startActivity(Intent intent) {
        String className = intent.getComponent().getClassName();
        if (mNeedLoginClassNames.contains(className)) {
            Intent loginIntent = new Intent(this, LoginActivity.class);
            loginIntent.putExtra("target", intent);
            super.startActivity(loginIntent);
        } else {
            super.startActivity(intent);
        }
    } */
}
